package com.itheima.tliaswebmanagement.mapper;

import com.github.pagehelper.Page;
import com.itheima.tliaswebmanagement.pojo.Clazz;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzMapper {

    @Delete("delete from clazz where id=#{id}")
    void deleteById(Integer id);

    @Insert("insert into clazz (id, name, room, begin_date, end_date, master_id, subject, create_time, update_time) VALUES (null,#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void add(Clazz clazz);

    @Select("select name, room, begin_date, end_date, master_id, subject, create_time, update_time from clazz where id=#{id}")
    Clazz findById(Integer id);


    void update(Clazz clazz);

    @Select("select * from clazz c left join emp e on c.master_id=e.id")
    List<Clazz> finAll();

    Page<Clazz> list(Clazz clazz);
}
